< previous page page_154 next page >

Page 154
e10a6a0a59f035e870d90cca05b85fce.gif
        ' Get the next word.
        pos = InStr(next_paragraph, " ")
        If pos = 0 Then
            ' Use the rest of the paragraph.
            next_word = next_paragraph
            next_paragraph = ""
        Else
            ' Get the word.
            next_word = Left$(next_paragraph, pos - 1)
            next_paragraph = _
                Trim$(Mid$(next_paragraph, pos + 1))
        End If

        ' See if there is room for this word.
        If Printer.CurrentX + _
            Printer.TextWidth(next_word) _
                > right_margin _
        Then
            ' It won't fit. Start a new line.
            Printer.Print
            Printer.CurrentX = left_margin

            ' See if we have room for a new line.
            If Printer.CurrentY +
                Printer.TextHeight(next_word) _
                > bottom_margin _
            Then
                ' Start a new page. 
                current_page = current_page + 1 
                If current_page > target_page _ 
                    Then Exit Sub 
                Printer.CurrentX = left_margin
                Printer.CurrentY = top_margin
            End If
        End If

        ' Now print the word. The ; makes the
        ' Printer not move to the next line.
        If current_page = target_page Then
            ' Print the word.
            If ptr Is Printer Then
                ' This is the printer. Print.
                ptr.Print next_word & " ";
         Else
             ' This is not the printer. Go to
             ' the printer's position and print.
             ptr.CurrentX = Printer.CurrentX
             ptr.CurrentY = Printer.CurrentY
             ptr.Print next_word & " ";

 
< previous page page_154 next page >